/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
  <div>
    <div
      id="explanation"
      class="explanation"
      style="color: rgb(85, 85, 85); background-color: rgb(243, 244, 244); width: 98%; height: 100%;"
    >
      <div class="bckopa-tips">
        <div class="title">
          <img src="@/static/images/handd.png" alt />
          <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
        </div>
        <ul>
          <li>1. 商家二级域名相关信息管理。</li>
          <li>2. 申请二级域名可提高网店的辨识度。</li>
        </ul>
      </div>
      <span title="收起提示" id="explanationZoom" style="display: block;"></span>
    </div>

    <div class="mDiv">
      <div class="ftitle">
        <h3>店铺域名列表</h3>
        <h5>(共 {{totalCount}} 条记录)</h5>
      </div>
      <a href class="refresh-date">
        <div title="刷新数据" class="pReload">
          <i class="fa fa-refresh"></i>
        </div>
      </a>
    </div>

    <div class="tablebox">
      <el-table :data="tableData" style="width: 100%">
        <el-table-column label="二级域名" width="180" prop="title" show-overflow-tooltip></el-table-column>
        <el-table-column label="编辑次数" width="180" prop="goods_name" show-overflow-tooltip></el-table-column>
        <el-table-column label="店铺名称" width="180" prop="buy_num"></el-table-column>
        <el-table-column label="店主名称" width="180" prop="price"></el-table-column>
        <el-table-column label="状态" prop="status_desc" width="180"></el-table-column>
        <el-table-column label="操作" width="180">
          <template slot-scope="scope">
            <el-button type="text" @click="toEdit(scope)">编辑</el-button>
            <el-button type="text" @click="delFn(scope.row.id)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        background
        class="paginationbox"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalCount"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [],
      currentPage: this.$route.params.currentPage || 1,
      totalCount: 0,
      pageSize: 5
    };
  },
  components: {},
  created() {
    this.getList();
  },
  methods: {
    handleSizeChange(e) {
      this.pageSize = e;
      this.getList();
    },
    handleCurrentChange(e) {
      this.currentPage = e;
      this.getList();
    },
    getList() {
      var that = this;
      this.request
        .get("/mall/flash_sales", {
          params: {
            p: that.currentPage,
            size: that.pageSize
          }
        })
        .then(function(res) {
          that.tableData = res.result.records;
          that.totalCount = res.result.total;
        });
    },
    delFn(id) {
      var that = this;
      this.$confirm("是否删除该信息?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          that.request.delete("/mall/flash_sales/" + id).then(function(res) {
            this.$message({
              type: "success",
              message: "删除成功!"
            });
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    toEdit(scope) {
      this.$router.push({
        name: "rush_edit",
        params: {
          obj: scope,
          currentPage: this.currentPage
        }
      }); //进入编辑页 保存本页面页码数据
    }
  }
};
</script>

<style scoped>
</style>
